<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>15.refs_create</title>
</head>
<body>
<div id="app"></div>

<script src="lib/react.development.js"></script>
<script src="lib/react-dom.development.js"></script>
<script src="lib/babel.min.js"></script>

<script type="text/babel">

    class Form extends  React.Component{
        container1 =React.createRef();
        container2 =React.createRef();
        getVal=()=>{
            const {current} =this.container1;
            alert(current.value);
        }



        getBlur =()=>{
            const {current} =this.container2;
            alert(current.value);

        }

        render(){
            return(
                <div>
                    <input type="text"  ref={this.container1} />
                    {/*
                       使用回调函数将当前节点保存在组件对象的某一个属性中
                    */}
                    <input type="button" value="提交" onClick={this.getVal} />
                    <input type="text" onBlur={this.getBlur}  ref={this.container2} />
                </div>
            )
        }
    }

    ReactDOM.render(<Form/>,document.getElementById("app"))
</script>
</body>
</html>